<%--
  Created by IntelliJ IDEA.
  User: 郝大哥
  Date: 2021/11/29
  Time: 10:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 百度ECHarts</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="<%=request.getContextPath()%>/resource/favicon.ico"> <link href="<%=request.getContextPath()%>/resource/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/resource/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="<%=request.getContextPath()%>/resource/css/animate.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/resource/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>中国疫情地图</h5>
                </div>
                <div class="ibox-content">
                    <div style="height:600px" id="echarts-map-chart"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script src="<%=request.getContextPath()%>/resource/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=request.getContextPath()%>/resource/js/bootstrap.min.js?v=3.3.6"></script>



<!-- ECharts -->
<script src="<%=request.getContextPath()%>/resource/js/plugins/echarts/echarts-all.js"></script>

<!-- 自定义js -->
<script src="<%=request.getContextPath()%>/resource/js/content.js?v=1.0.0"></script>
<script>
    $(function(){//页面加载的时候进行调用
        $.ajax({
            url:"<%=request.getContextPath()%>/yq/getChina",
            type:"get",
            dataType:"json",
            success:function(res){
                console.log(res);
                var value=[];//确诊 {name:..,value:...}
                var cureNum=[];//治愈
                var econNum=[];//未治愈
                var deathNum=[];//死亡
                for(var i=0;i<res.length;i++){
                    value.push({"name":res[i].name,"value":res[i].value});
                    cureNum.push({"name":res[i].name,"value":res[i].cureNum});
                    econNum.push({"name":res[i].name,"value":res[i].econNum});
                    deathNum.push({"name":res[i].name,"value":res[i].deathNum});
                }
                //1、绑定图表的div，初始化图表信息
                var myEcharts=echarts.init(document.getElementById("echarts-map-chart"));
                //2、设置图表的选项
                var option = {
                    // 默认色板
                    color: ['#303917','#87cefa','#da70d6','#32cd32','#6495ed',
                        '#ff69b4','#ba55d3','#cd5c5c','#ffa500','#40e0d0',
                        '#1e90ff','#ff6347','#7b68ee','#00fa9a','#ffd700',
                        '#6699FF','#ff6666','#3cb371','#b8860b','#30e0e0'],
                    title : {
                        text: '中国疫情分布情况',//主标题
                        subtext: '数据来源于新浪',//副标题
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item'
                    },
                    legend: {
                        orient: 'vertical',
                        x:'left',
                        data:['确诊','未痊愈','死亡','治愈']
                    },
                    dataRange: {
                        min: 0,
                        max: 5000,
                        text:['高','低'],           // 文本，默认为数值文本
                        calculable : true,
                        textStyle: {
                            color: 'orange'
                        }
                    },
                    toolbox: {
                        show : true,
                        orient : 'vertical',
                        x: 'right',
                        y: 'center',
                        feature : {
                            mark : true,
                            dataView : {readOnly: false},
                            restore : true,
                            saveAsImage : true
                        }
                    },
                    series : [
                        {
                            name: '确诊',
                            type: 'map',
                            mapType: 'china',
                            itemStyle:{
                                normal:{label:{show:true}, color:'#ffd700'},// for legend
                                emphasis:{label:{show:true}}
                            },
                            data:value
                        },
                        {
                            name: '未痊愈',
                            type: 'map',
                            mapType: 'china',
                            itemStyle:{
                                normal:{label:{show:true}, color:'#ff3c00'},// for legend
                                emphasis:{label:{show:true}}
                            },
                            data:econNum
                        },
                        {
                            name: '死亡',
                            type: 'map',
                            mapType: 'china',
                            itemStyle:{
                                normal:{label:{show:true}, color:'#0c0108'},// for legend
                                emphasis:{label:{show:true}}
                            },
                            data:deathNum
                        },
                        {
                            name: '治愈',
                            type: 'map',
                            mapType: 'china',
                            itemStyle:{
                                normal:{label:{show:true}, color:'#18bb1b'},// for legend
                                emphasis:{label:{show:true}}
                            },
                            data:cureNum
                        }
                    ]
                };
                //3、加载图片选项
                myEcharts.setOption(option);
            }
        });
    })
</script>



</body>

</html>

